#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
from ._base import CrmConfig, AdminConfig, ApiConfig


all = ['LocalCrmConfig', 'LocalAdminConfig, LocalApiConfig']

uppath = lambda _path, n: os.sep.join(_path.split(os.sep)[:-n])


class LocalMixin(object):

    WEB_HOST = 'http://127.0.0.1:5001/'

    # SQLALCHEMY_DATABASE_URI = "mysql+pymysql://dev:123456@127.0.0.1:3306/big_data?charset=utf8mb4"
    # SQLALCHEMY_BINDS = {
    #     'fx': 'mysql+pymysql://dev:123456@127.0.0.1:3306/big_data?charset=utf8mb4',
    # }
    SQLALCHEMY_DATABASE_URI = "mysql+pymysql://big_data:Linlong219@rm-bp193z0m7lmk92b813o.mysql.rds.aliyuncs.com:3306/fan_xian_dev?charset=utf8mb4"
    SQLALCHEMY_BINDS = {
        'fx': "mysql+pymysql://big_data:Linlong219@rm-bp193z0m7lmk92b813o.mysql.rds.aliyuncs.com:3306/fan_xian_dev?charset=utf8mb4",
    }
    RUN_ENV = 'local'
    DEBUG = True
    PROPAGATE_EXCEPTIONS = True
    MOBILE_ENABLE = True

    REDIS_DB = 1
    REDIS_HOST = '127.0.0.1'
    REDIS_PORT = 6379

    UPLOAD_FOLDER = os.path.join(uppath(__file__, 2), "static/upload/")
    IMAGES_DOMAIN = '/static/upload/'

    # celery 配置
    CELERY_BROKER_URL = 'redis://localhost:6379'

    def __init__(self):
        self.LOGGERS['fx']['level'] = 'DEBUG'


class LocalCrmConfig(LocalMixin, CrmConfig):
    pass


class LocalAdminConfig(LocalMixin, AdminConfig):
    pass


class LocalApiConfig(LocalMixin, ApiConfig):
    pass
